package com.cupcorn.lib.game.element;

import com.cupcorn.lib.Anchor;
import com.cupcorn.lib.Ratio;
import com.cupcorn.lib.define.iDefines;
import com.cupcorn.lib.game.GameEngine;

public class GameElementSprite extends GameElementShape
{
	public String path;
	
	public GameElementSprite(String path, float x, float y, Anchor anchor, Ratio ratio)
	{
		this(path, x, y, 0, 0, anchor, ratio);
	}
	
	public GameElementSprite(String path, float x, float y, float width, float height, Anchor anchor, Ratio ratio)
	{
		super(x, y, width, height, anchor, ratio);
		this.path = getAssetFolder(detectDPI())+path;
	}
	
	private static float detectDPI()
	{
		switch(GameEngine.getInstance().gameOrientation())
		{
			case LANDSCAPE_FIXED:
			case LANDSCAPE_SENSOR:
			{
				return GameEngine.getGameWidth();
			}
			case PORTRAIT_FIXED:
			case PORTRAIT_SENSOR:
			{
				return GameEngine.getGameHeight();
			}
		}
		
		return 0;
	}
	
	private static String getAssetFolder(float dpi)
	{
		if(dpi <= iDefines.MINI_DPI)
		{
			return iDefines.MINI_PATH;
		}
		
		if(dpi <= iDefines.LARGE_DPI)
		{
			return iDefines.LARGE_PATH;
		}
		
		return iDefines.HIGH_PATH;
	}
	
}
